package com.zxzw.scanningin.http

import android.util.Log
import com.tencent.mmkv.MMKV
import com.zxzw.scanningin.http.AppConfig
import kotlinx.coroutines.runBlocking
import okhttp3.Interceptor
import okhttp3.Response

/**
 * Author: zx
 * Data:  2023/11/6
 * 添加请求头
 */
class HeaderInterceptor : Interceptor{
    private val token = runBlocking {
        MMKV.defaultMMKV().decodeString("token")
    }
    override fun intercept(chain: Interceptor.Chain): Response {

        Log.e("<<<<<<<<<<<<","啥也没有?${AppConfig.token}")
        var request = chain.request()
        var addHeader = request.newBuilder().addHeader("Authorization", AppConfig.token).build()

        return chain.proceed(addHeader)

    }


}